# keyboard.py
# keyboard utilities
import pygame
# this is the list of all available keys
# changing the order of this list will change the order in pug dropdowns
key_list = [
    (None,None),
    ("UP",273),
    ("DOWN",274),
    ("LEFT",276),
    ("RIGHT",275),
    ("SPACE",32),
    ("LEFT_MOUSE",1001),
    ("RIGHT_MOUSE",1003),
    ("A",97),
    ("B",98),
    ("C",99),
    ("D",100),
    ("E",101),
    ("F",102),
    ("G",103),
    ("H",104),
    ("I",105),
    ("J",106),
    ("K",107),
    ("L",108),
    ("M",109),
    ("N",110),
    ("O",111),
    ("P",112),
    ("Q",113),
    ("R",114),
    ("S",115),
    ("T",116),
    ("U",117),
    ("V",118),
    ("W",119),
    ("X",120),
    ("Y",121),
    ("Z",122),
    ("0",48),
    ("1",49),
    ("2",50),
    ("3",51),
    ("4",52),
    ("5",53),
    ("6",54),
    ("7",55),
    ("8",56),
    ("9",57),
    ("AMPERSAND",38),
    ("ASTERISK",42),
    ("AT",64),
    ("BACKQUOTE",96),
    ("BACKSLASH",92),
    ("BACKSPACE",8),
    ("BREAK",318),
    ("CAPSLOCK",301),
    ("CARET",94),
    ("CLEAR",12),
    ("COLON",58),
    ("COMMA",44),
    ("COMPOSE",314),
    ("DELETE",127),
    ("DOLLAR",36),
    ("END",279),
    ("EQUALS",61),
    ("ESCAPE",27),
    ("EURO",321),
    ("EXCLAIM",33),
    ("F1",282),
    ("F10",291),
    ("F11",292),
    ("F12",293),
    ("F13",294),
    ("F14",295),
    ("F15",296),
    ("F2",283),
    ("F3",284),
    ("F4",285),
    ("F5",286),
    ("F6",287),
    ("F7",288),
    ("F8",289),
    ("F9",290),
    ("FIRST",0),
    ("GREATER",62),
    ("HASH",35),
    ("HELP",315),
    ("HOME",278),
    ("INSERT",277),
    ("KP0",256),
    ("KP1",257),
    ("KP2",258),
    ("KP3",259),
    ("KP4",260),
    ("KP5",261),
    ("KP6",262),
    ("KP7",263),
    ("KP8",264),
    ("KP9",265),
    ("KP_DIVIDE",267),
    ("KP_ENTER",271),
    ("KP_EQUALS",272),
    ("KP_MINUS",269),
    ("KP_MULTIPLY",268),
    ("KP_PERIOD",266),
    ("KP_PLUS",270),
    ("LALT",308),
    ("LCTRL",306),
    ("LEFTBRACKET",91),
    ("LEFTPAREN",40),
    ("LESS",60),
    ("LMETA",310),
    ("LSHIFT",304),
    ("LSUPER",311),
    ("MENU",319),
    ("MINUS",45),
    ("MODE",313),
    ("NUMLOCK",300),
    ("PAGEDOWN",281),
    ("PAGEUP",280),
    ("PAUSE",19),
    ("PERIOD",46),
    ("PLUS",43),
    ("POWER",320),
    ("PRINT",316),
    ("QUESTION",63),
    ("QUOTE",39),
    ("QUOTEDBL",34),
    ("RALT",307),
    ("RCTRL",305),
    ("RETURN",13),
    ("RIGHTBRACKET",93),
    ("RIGHTPAREN",41),
    ("RMETA",309),
    ("RSHIFT",303),
    ("RSUPER",312),
    ("SCROLLOCK",302),
    ("SEMICOLON",59),
    ("SLASH",47),
    ("SYSREQ",317),
    ("TAB",9),
    ("UNDERSCORE",95),
    ("UNDO",322),
    ("UNKNOWN",0),
    ("MIDI",1100),
#    ("MIDI_1",1101),
#    ("MIDI_2",1102),
#    ("MIDI_3",1103),
#    ("MIDI_4",1104),
#    ("MIDI_5",1105),
#    ("MIDI_6",1106),
#    ("MIDI_7",1107),
#    ("MIDI_8",1108),
#    ("WORLD_0",160),
#    ("WORLD_1",161),
#    ("WORLD_10",170),
#    ("WORLD_11",171),
#    ("WORLD_12",172),
#    ("WORLD_13",173),
#    ("WORLD_14",174),
#    ("WORLD_15",175),
#    ("WORLD_16",176),
#    ("WORLD_17",177),
#    ("WORLD_18",178),
#    ("WORLD_19",179),
#    ("WORLD_2",162),
#    ("WORLD_20",180),
#    ("WORLD_21",181),
#    ("WORLD_22",182),
#    ("WORLD_23",183),
#    ("WORLD_24",184),
#    ("WORLD_25",185),
#    ("WORLD_26",186),
#    ("WORLD_27",187),
#    ("WORLD_28",188),
#    ("WORLD_29",189),
#    ("WORLD_3",163),
#    ("WORLD_30",190),
#    ("WORLD_31",191),
#    ("WORLD_32",192),
#    ("WORLD_33",193),
#    ("WORLD_34",194),
#    ("WORLD_35",195),
#    ("WORLD_36",196),
#    ("WORLD_37",197),
#    ("WORLD_38",198),
#    ("WORLD_39",199),
#    ("WORLD_4",164),
#    ("WORLD_40",200),
#    ("WORLD_41",201),
#    ("WORLD_42",202),
#    ("WORLD_43",203),
#    ("WORLD_44",204),
#    ("WORLD_45",205),
#    ("WORLD_46",206),
#    ("WORLD_47",207),
#    ("WORLD_48",208),
#    ("WORLD_49",209),
#    ("WORLD_5",165),
#    ("WORLD_50",210),
#    ("WORLD_51",211),
#    ("WORLD_52",212),
#    ("WORLD_53",213),
#    ("WORLD_54",214),
#    ("WORLD_55",215),
#    ("WORLD_56",216),
#    ("WORLD_57",217),
#    ("WORLD_58",218),
#    ("WORLD_59",219),
#    ("WORLD_6",166),
#    ("WORLD_60",220),
#    ("WORLD_61",221),
#    ("WORLD_62",222),
#    ("WORLD_63",223),
#    ("WORLD_64",224),
#    ("WORLD_65",225),
#    ("WORLD_66",226),
#    ("WORLD_67",227),
#    ("WORLD_68",228),
#    ("WORLD_69",229),
#    ("WORLD_7",167),
#    ("WORLD_70",230),
#    ("WORLD_71",231),
#    ("WORLD_72",232),
#    ("WORLD_73",233),
#    ("WORLD_74",234),
#    ("WORLD_75",235),
#    ("WORLD_76",236),
#    ("WORLD_77",237),
#    ("WORLD_78",238),
#    ("WORLD_79",239),
#    ("WORLD_8",168),
#    ("WORLD_80",240),
#    ("WORLD_81",241),
#    ("WORLD_82",242),
#    ("WORLD_83",243),
#    ("WORLD_84",244),
#    ("WORLD_85",245),
#    ("WORLD_86",246),
#    ("WORLD_87",247),
#    ("WORLD_88",248),
#    ("WORLD_89",249),
#    ("WORLD_9",169),
#    ("WORLD_90",250),
#    ("WORLD_91",251),
#    ("WORLD_92",252),
#    ("WORLD_93",253),
#    ("WORLD_94",254),
#    ("WORLD_95",255),
]
# create constant values and dict
keys = {}
for _name, _val in key_list:
    keys[_name] = _val
    
# list of keymods
# lshift = 1, rshift = 2, lctrl = 64, rctrl = 128, lalt = 256, ralt = 512
keymod_list = (
    ("", 0),
    ("SHIFT", pygame.KMOD_SHIFT),
    ("CTRL", pygame.KMOD_CTRL),
    ("ALT", pygame.KMOD_ALT)
)
# create constant values and dict
keymods = {}
for _name, _val in keymod_list:
    keymods[_name] = _val

